#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

DEPTH		= @DEPTH@
topsrcdir	= @top_srcdir@
srcdir		= @srcdir@
VPATH		= @srcdir@

include $(DEPTH)/config/autoconf.mk

MODULE		= xpcshell
PROGRAM		= xpcshell$(BIN_SUFFIX)
SDK_BINARY	= $(PROGRAM)

CPPSRCS		= xpcshell.cpp

LOCAL_INCLUDES += \
  -I$(topsrcdir)/toolkit/xre \
  $(NULL)

ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
CMMSRCS += xpcshellMacUtils.mm
endif

ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
  ifdef MOZ_APP_PROFILE
    DEFINES += -DMOZ_APP_PROFILE='"$(MOZ_APP_PROFILE)"'
  else
    ifdef MOZ_APP_VENDOR
      DEFINES += -DMOZ_APP_VENDOR='"$(MOZ_APP_VENDOR)"'
    endif
    ifdef MOZ_APP_BASENAME
      DEFINES += -DMOZ_APP_BASENAME='"$(MOZ_APP_BASENAME)"'
    endif
    DEFINES += -DMOZ_APP_NAME='"$(MOZ_APP_NAME)"'
  endif
endif

LIBS		= \
		$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
		$(LIBXUL_LIBS) \
		$(XPCOM_LIBS) \
		$(NULL)

ifdef JS_SHARED_LIBRARY
LIBS +=	$(MOZ_JS_LIBS)
endif

LIBS +=	$(NSPR_LIBS)

NSDISTMODE = copy

ifdef _MSC_VER
ifeq ($(OS_TEST),x86_64)
# set stack to 2MB on x64 build.  See bug 582910
WIN32_EXE_LDFLAGS += -STACK:2097152
endif
endif

ifeq ($(OS_TEST),ia64)
LIBS += $(JEMALLOC_LIBS)
endif
include $(topsrcdir)/config/config.mk

ifdef _MSC_VER
# Always enter a Windows program through wmain, whether or not we're
# a console application.
WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
endif

include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk

DEFINES		+= -DJS_THREADSAFE

ifdef MOZ_SHARK
DEFINES += -DMOZ_SHARK
CFLAGS += -F/System/Library/PrivateFrameworks
LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
endif
ifdef MOZ_CALLGRIND
DEFINES += -DMOZ_CALLGRIND
endif
ifdef MOZ_VTUNE
DEFINES += -DMOZ_VTUNE
CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
endif
#
# Line editing support.  If your OS supplies the readline library, define
# JS_READLINE to get line editing in the xpcshell.
#
# If you can't link against readline because of GPL licensing issues
# (which may not apply, as xpcshell.c has the dual license) you might
# look at mozilla/js/src/editline, which is license-free (but not part
# of the mozilla build.)
#
ifdef JS_READLINE
DEFINES += -DEDITLINE
LIBS += -lreadline $(JS_READLINE_EXTRA_LIBS)
endif
